package com.z.controller;

import com.alibaba.fastjson.JSON;
import com.z.service.GoodsService;
import com.z.service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteGoodsByGid")
public class DeleteGoodsServlet extends HttpServlet {
    private final GoodsService goodsService = new GoodsServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String gid = req.getParameter("gid");
        Integer goods = goodsService.deleteGoods(Integer.valueOf(gid));

        resp.getWriter().write(JSON.toJSONString(goods));
    }
}
